<style src="../../style/statistics.css" scoped>

</style>
<template>
    <div style="height:100%;" class="padding10">
        <Row class="divBar">
            <!--搜索框-->
                <Col span="14" >
                    <label  v-show="userInfo.AreaCode=='530000000000'">所属地区:</label>
                    <Select v-model="searchModel.AreaCode" placeholder="全部" :label-in-value="true" @on-change="getData()" style="width:120px" v-show="userInfo.AreaCode=='530000000000'">
                        <Option :value="item.value" v-for="item in AreaList" :key="item.value">{{item.label}}</Option>
                    </Select>
                    <span v-show="!lineShow">填报年度:</span>
                    <Select v-model="searchModel.FillInYear" placeholder="全部" :label-in-value="true" @on-change="getData()" v-show="!lineShow" style="width:120px">
                        <!-- <Option value="">全部</Option> -->
                        <Option :value="item.DictValue" v-for="item in CreateYearList" :key="item.DictValue">{{item.DictText}}</Option>
                    </Select> 
                    <Button  type="primary" v-show="listShow" @click="Download()">导出列表</Button>
                </Col>                   
                <Col :span="(lineShow&&userInfo.AreaCode!='530000000000')?24:10"  style="text-align:right;">   
                   <!-- <Button type="success" @click="toAlertCheckResult()" style="margin-top:5px;margin-right:50px">数据检测</Button>                         -->
                    <RadioGroup v-model="currentButton" @on-change="changeButton" type="button"  size="large">
                        <Radio label="listShow" title="列表"><Icon type="ios-paper" size="35"></Icon></Radio>                            
                        <Radio label="pieShow" title="饼图"><Icon type="ios-pie" size="35"></Icon></Radio>
                        <Radio label="lineShow" title="折线图"><Icon type="ios-pulse" size="35"></Icon></Radio>
                        <Radio label="mapShow" title="地图"><Icon type="android-map" size="35"></Icon></Radio>                            
                    </RadioGroup>                    
              </Col>                                
            </Row>           
            <Row  v-show="listShow">
            <!-- 列表-->
            <div class="col-margin" >
              <Table  :columns="columnList" no-data-text="暂无数据" :data="datalist" border :height="clientHeight"></Table>
              <!-- <div style="overflow-x:auto;margin-bottom:40px;">
                <table  class="statisTable" :style="tableStyle" v-show="!isCounty">
                  <thead>
                    <tr>
                      <th style="width:100px" rowspan="2">地区</th>
                      <th style="width:240px" colspan="4">马铃薯市场（个）</th>
                      <th style="width:360px" colspan="6">马铃薯企业（个）</th>
                      <th style="width:650px" colspan="5">马铃薯农民合作社</th>
                    <tr>
                      <th >总数</th>
                      <th >产地性市场</th>
                      <th >专业批发市场</th>
                      <th >区域性综合批发市场</th>
                      <th >总数</th>
                      <th >国家级龙头企业</th>
                      <th >省级龙头企业</th>
                      <th >州（市）级龙头企业</th>
                      <th >县（市、区）级龙头企业</th>
                      <th >其他</th>
                      <th >马铃薯农民合作社数量（个）</th>
                      <th >参加马铃薯农民合作社农户数（户）</th>
                      <th >合作社经营面积（亩）</th>
                      <th >其中：流转土地面积（亩）</th>
                      <th >合作社年销售收入（万元）</th>
                    </tr>
                  </thead>
                  <tbody>
                      <tr v-for="(item,index) in datalist" :key="index" :style="rowStyle(index,datalist.length)">
                               <td style="text-align:center;width:100px;">{{item.AreaName}}</td>                                    
                               <td style="width:60px">{{FormatBigNum(item.MarketNum)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.CdxMarket)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.ZypfMarket)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.QyxzhpfMarket)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.FruCompanyNum)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.ZzNum_country)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.ZzNum_pro)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.ZzNum_city)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.ZzNum_county)}}</td>
                               <td style="width:60px">{{FormatBigNum(item.ZzNum_other)}}</td>
                               <td style="width:130px">{{FormatBigNum(item.HzNum)}}</td>
                               <td style="width:130px">{{FormatBigNum(item.HznhNum)}}</td>
                               <td style="width:130px">{{(item.NmhzArea)?FormatBigNum(item.NmhzArea.toFixed(2)):''}}</td>
                               <td style="width:130px">{{(item.HzlzArea)?FormatBigNum(item.HzlzArea.toFixed(2)):''}}</td>
                               <td style="width:130px">{{(item.NmhzYincome)?FormatBigNum(item.NmhzYincome.toFixed(2)):''}}</td>
                      </tr>
                  </tbody>
                </table>    
                
                <table  class="statisTable" :style="tableStyle" v-show="isCounty">                   
                    <thead>
                    <tr>
                        <th >名称</th>
                        <th >计量单位</th>
                        <th >数量</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr style="background:#ebf7ff">
                        <td style="text-align:left;font-weight:bold">一、马铃薯市场个数</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.MarketNum}}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">其中：产地性市场</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.CdxMarket}}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">专业批发市场</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.ZypfMarket}}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">区域性综合批发市场</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.QyxzhpfMarket}}
                        </td>
                    </tr>
                    <tr style="background:#ebf7ff">
                        <td style="text-align:left;font-weight:bold">二、马铃薯企业个数</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.FruCompanyNum}}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">其中：国家级龙头企业</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.ZzNum_country}}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">省级龙头企业</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.ZzNum_pro}}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">州（市）级龙头企业</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.ZzNum_city}}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">县（市、区）级龙头企业</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.ZzNum_county}}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">其他</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">
                            {{DataModel.ZzNum_otder}}
                        </td>
                    </tr>                    
                    <tr style="background:#f9c912">
                        <td colspan="3" style="text-align:left;font-weight:bold">三、马铃薯农民合作社</td>                       
                    </tr>
                    <tr>
                        <td style="text-align:center;">1.农民合作社数量</td>
                        <td style="text-align:center;">个</td>
                        <td style="text-align:center;">{{DataModel.HzNum}}</td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">2.参加农民合作社农户数</td>
                        <td style="text-align:center;">户</td>
                        <td style="text-align:center;">{{DataModel.HznhNum}}</td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">3.农民专业合作组织经营面积</td>
                        <td style="text-align:center;">亩</td>
                        <td style="text-align:center;">{{DataModel.NmhzArea}}</td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">其中：流转土地面积</td>
                        <td style="text-align:center;">亩</td>
                        <td style="text-align:center;">{{DataModel.HzlzArea}}</td>
                    </tr>
                    <tr>
                        <td style="text-align:center;">4.农民合作社年销售收入</td>
                        <td style="text-align:center;">万元</td>
                        <td style="text-align:center;">{{DataModel.NmhzYincome}}</td>
                    </tr>                   
                    </tbody>
                </table> 
                </div>-->
            </div>
         </Row>
         <Row v-show="pieShow"  style="border:1px solid #D7DDE4; ">   
             <Row>
                <Col span="12">
                   <div id="marketPie" :style="pieColStyle"></div>
                </Col>
                <Col span="12">
                   <div id="companyPie" :style="pieColStyle"></div>
                </Col>
              </Row>
              <!--  <Row>
                <Col span="24">
                   <div id="nmhzBar" :style="pieRowStyle"></div>
                </Col>
              </Row>      -->
        </Row>
        <Row v-show="lineShow" style="border:1px solid #D7DDE4;overflow:auto">
            <!--折线图-->
            <div style="border:1px solid #D7DDE4;padding:10px;margin:5px" >
                <!-- <span style="font-size:18px">指标集合：</span> -->
            <RadioGroup v-model="propIndex" @on-change="showLine()">
                <Radio :label="index" v-for="(item,index) in PropNameList" :key="index">{{item}}</Radio>
            </RadioGroup>
            </div>
            <div  id="divLine" style="width:1200px;height:670px;"></div>
        </Row>
        <Row  v-show="mapShow">
            <!--地图展示-->
            <Tabs type="card">
                <TabPane label="马铃薯市场">
                    <div id="divMapOne" style="border:1px solid #D7DDE4; "></div>
                </TabPane>
                <TabPane label="马铃薯企业">
                    <div id="divMapTwo" style="border:1px solid #D7DDE4;"></div>
                </TabPane>
                <TabPane label="马铃薯农民合作社">
                    <div id="divMapThree" style="border:1px solid #D7DDE4; "></div>
                </TabPane>
            </Tabs>
        </Row>
        
    </div>
</template>
<script>
import echarts from "echarts";
export default {
  data() {
    return {
      pieColStyle: {
        height: window.innerHeight - 190 + "px",
        width: (window.innerWidth - 350) / 2 + "px"
      },
      pieRowStyle: {
        height: window.innerHeight - 190 + "px",
        width: window.innerWidth - 350 + "px"
      },
      isCounty:false,//是否是区县级
      showType: false,
      DataModel:'',//区县级对象
      currentButton: "listShow",
      listShow: true, //列表显示控制器
      pieShow: false, //饼图显示控制器
      mapShow: false, //地图显示控制器
      lineShow: false, //折线图显示控制器
      userInfo: '',
      statusList: this.GetGroupDict("ReportStatus"),
      AreaList: [], //所属行政区划数组,
      CreateYearList: this.GetGroupDict("ReportYear"), //周期
      CycleList: this.GetGroupDict("ReportCycle"), //
      datalist: [], //列表对象
      columnList:[
        {title:'地区',key:'AreaName',align:'center',fixed:'left',width:180},
        {title:'马铃薯市场（个）',align:'center',children:[
          {title:'总数',key:'MarketNum',align:'right',sortable: true,width:84},
          {title:'产地性市场',key:'CdxMarket',align:'right',sortable: true,width:84},
          {title:'专业批发市场',key:'ZypfMarket',align:'right',sortable: true,width:84},
          {title:'区域性综合批发市场',key:'QyxzhpfMarket',align:'right',sortable: true,width:84},
        ]},
        {title:'马铃薯企业（个）',align:'center',children:[
            {title:'总数',key:'FruCompanyNum',align:'right',sortable: true,width:84},
            {title:'国家级龙头企业',key:'ZzNum_country',align:'right',sortable: true,width:84},
            {title:'省级龙头企业',key:'ZzNum_pro',align:'right',sortable: true,width:84},
            {title:'州（市）级龙头企业',key:'ZzNum_city',align:'right',sortable: true,width:84},
            {title:'县（市、区）级龙头企业',key:'ZzNum_county',align:'right',sortable: true,width:84},
            {title:'其他',key:'ZzNum_otder',align:'right',sortable: true,width:85},
        ]},
        {title:'马铃薯农民合作社',align:'center',children:[
            {title:'马铃薯农民合作社数量（个）',key:'HzNum',width:120,align:'right',sortable: true},
            {title:'参加马铃薯农民合作社农户数（户）',key:'HznhNum',width:120,align:'right',sortable: true},
            {title:'合作社经营面积（亩）',key:'NmhzArea',width:120,align:'right',sortable: true},
            {title:'其中：流转土地面积（亩）',key:'HzlzArea',width:120,align:'right',sortable: true},
            {title:'合作社年销售收入（万元）',key:'NmhzYincome',width:120,align:'right',sortable: true},
        ]},
      ],
      tableStyle:{
          height:window.innerHeight - 183+'px',
          //marginBottom:'50px',
          //width:'1500px'
      },
      //查询模型：根据需求删除不不要查询条件
      searchModel: {
        ReportCode: "PotProsecution",
        FillInYear: new Date().getFullYear() + "",
        AreaCode: this.GetlocaStorage("potUserinfo").AreaCode,
        Status: "",
        PageNumber: 1,
        PageSize: 20
      },
      CurrentAreaName:'',
      mapType:'',
      echartsItem0:['马铃薯市场总数','产地批发市场','专业批发市场','区域性综合批发市场'],
      echartsItem1:['马铃薯企业总数','国家级龙头企业','省级龙头企业','州(市)级龙头企业','县(市、区)级龙头企业','其他'],
      echartsItem2:['马铃薯农民合作社数量','参加马铃薯农民合作社农户数','马铃薯农民合作社经营面积','流转土地面积','马铃薯农民合作社年销售收入'],
      GeoData:'',
      //地图数据
      //马铃薯市场
      MapMarketNumData:[],
      MapCdxMarketData:[],
      MapZypfMarketData:[],
      MapQyxzhpfMarketData:[],
      //马铃薯企业
      MapFruCompanyNumData:[],
      MapZzNum_CountryData:[],
      MapZzNum_ProData:[],
      MapZzNum_CityData:[],
      MapZzNum_AreaData:[],
      MapZzNum_OtherData:[],
      //马铃薯农民合作社
      MapHzNumData:[],
      MapNhNumData:[],
      MapZyhzNumData:[],
      MapNmzyhzNumData:[],
      MapHzlzAreaData:[],//合作流转面积
      MapNmhzYincomeData:[],//合作社年销售收入（万元）
      mapList0:[],
      mapList1:[],
      mapList2:[],
      mapList3:[],
      mapList4:[],
      clientHeight: window.innerHeight - 185, //表格默认高度
      //折线图数据
      PropDataList:[],
      propIndex:0,//指标索引
      PropNameList:['马铃薯市场总数','产地性市场 ','专业批发市场','区域性综合批发市场','马铃薯企业总数','国家级龙头企业 ','省级龙头企业 ','州（市）级龙头企业 ','县（市、区）级龙头企业','其他企业',
      '马铃薯农民合作社数量（个）','参加马铃薯农民合作社农户数（户）','合作社经营面积（亩）','其中：流转土地面积（亩）','合作社年销售收入（万元）'],//指标名称列表
    };
  },
  mounted() {
    //table高度计算方法
    const that = this;
    window.onresize = () => {
      return (() => {
        that.clientHeight = window.innerHeight - 185;
      })();
    };
  },
  methods: {
    //初始化行政区划树
    SearchAreaList() {
      var areaCode = this.userInfo.AreaCode;
      var areaList=[];
      var templist = [];
      var areaEntity = new Object();
      areaEntity.value=areaCode;
      areaEntity.children=[];
      if (areaCode != '530000000000' && areaCode != null) {
          var item = this.GetlocaStorage("areatreelist")[0];
          areaEntity.label="全州（市）";
          for (var i = 0; i < item.children.length; i++) {
              if (item.children[i].value == areaCode) {
                  areaList.push(item.children[i]);
              }
          }
      } else {
          areaEntity.label="全省";
          areaList = this.GetlocaStorage("areatreelist");
      }
      templist.push(areaEntity);
        this.AreaList=templist.concat(areaList[0].children);
    },
    changeButton(n) {
      if (n == "listShow") {
        this.listShow = true; //显示列表
        this.pieShow = false;
        this.mapShow = false;
        this.lineShow = false;
      } else if (n == "pieShow") {
        this.listShow = false;
        this.pieShow = true; //显示饼图
        this.mapShow = false;
        this.lineShow = false;
        this.showPie();
      } 
      else if(n=="lineShow")
      {
        this.listShow=false;
        this.lineShow=true;//显示折线图
        this.mapShow=false;
        this.pieShow=false;
        this.showLine();
      }
      else if (n == "mapShow") {
        this.listShow = false;
        this.pieShow = false; //显示地图
        this.mapShow = true;
        this.lineShow = false;
        //  this.getStatsData();   //获取地区统计数据
        //this.showMap();
      } else {
        this.listShow = true; //默认显示列表
        this.pieShow = false;
        this.mapShow = false;
        this.lineShow = false;
      }
    },
    rowStyle(index, length) {
      let striprow = { backgroundColor: "#ebf7ff" };
      if (index == length - 1) {
        return {
          backgroundColor: "#f9c912"
        };
      } else if (index % 2 != 0) {
        return striprow;
      } else {
        return;
      }
    },
    rowclass(item, index) {
      let striprow = {
        backgroundColor: "#ebf7ff"
      };
      let cityrow = {
        backgroundColor: "#f9c912"
      };
      let provinrow = {
        backgroundColor: "#183"
      };
      if (index % 2 == 0) {
        if (item.tag == 1) {
          return cityrow;
        } else if (item.tag == 2) {
          return provinrow;
        }
      } else {
        if (item.tag == 1) {
          return cityrow;
        } else if (item.tag == 2) {
          return provinrow;
        } else {
          return striprow;
        }
      }
    },
    showPie() {
      this.initMarketPie();
      this.initCompanyPie();
    },
    initMarketPie() {
      var self = this;
      let myChart = echarts.init(document.getElementById("marketPie"));
      let xlist = [];
      let MarketNumlist = [];
      let CdxMarketlist = [];
      let ZypfMarketlist = [];
      let QyxzhpfMarketlist = [];

      for (let i = 0; i < this.datalist.length - 1; i++) {
        let item = this.datalist[i];
        xlist.push(item.AreaName);
        MarketNumlist.push({ value: item.MarketNum, name: item.AreaName });
        CdxMarketlist.push({ value: item.CdxMarket, name: item.AreaName });
        ZypfMarketlist.push({ value: item.ZypfMarket, name: item.AreaName });
        QyxzhpfMarketlist.push({
          value: item.QyxzhpfMarket,
          name: item.AreaName
        });
      }
      let option = {
        title: {
          text: "马铃薯市场",
          subtext: "单位：个",
          x: "center"
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          x: "left",
          data: xlist
        },
        series: [
          {
            name: "马铃薯市场",
            type: "pie",
            selectedMode: "single",
            radius: [0, "10%"],
            label: {
              normal: {
                position: "inner"
              }
            },
            labelLine: {
              normal: {
                show: false
              }
            },
            data: MarketNumlist
          },
          {
            name: "产地性市场",
            type: "pie",
            radius: ["15%", "25%"],
            data: CdxMarketlist
          },
          {
            name: "专业批发市场",
            type: "pie",
            radius: ["30%", "45%"],
            data: ZypfMarketlist
          },
          {
            name: "区域性综合批发市场",
            type: "pie",
            radius: ["50%", "65%"],
            data: QyxzhpfMarketlist
          }
        ]
      };
      myChart.setOption(option);
    },
    initCompanyPie() {
      var self = this;
      let myChart = echarts.init(document.getElementById("companyPie"));
      let xlist = [];
      let FruCompanyNumlist = [];
      let ZzNum_countrylist = [];
      let ZzNum_prolist = [];
      let ZzNum_citylist = [];
      let ZzNum_countylist = [];
      let ZzNum_otherlist = [];

      for (let i = 0; i < this.datalist.length - 1; i++) {
        let item = this.datalist[i];
        xlist.push(item.AreaName);
        FruCompanyNumlist.push({
          value: item.FruCompanyNum,
          name: item.AreaName
        });
        ZzNum_countrylist.push({
          value: item.ZzNum_country,
          name: item.AreaName
        });
        ZzNum_prolist.push({ value: item.ZzNum_pro, name: item.AreaName });
        ZzNum_citylist.push({ value: item.ZzNum_city, name: item.AreaName });
        ZzNum_countylist.push({
          value: item.ZzNum_county,
          name: item.AreaName
        });
        ZzNum_otherlist.push({ value: item.ZzNum_other, name: item.AreaName });
      }
      let option = {
        title: {
          text: "马铃薯企业",
          subtext: "单位：个",
          x: "center"
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          x: "right",
          data: xlist
        },
        series: [
          {
            name: "马铃薯企业",
            type: "pie",
            selectedMode: "single",
            radius: [0, "10%"],
            label: {
              normal: {
                position: "inner"
              }
            },
            labelLine: {
              normal: {
                show: false
              }
            },
            data: FruCompanyNumlist
          },
          {
            name: "国家级龙头企业",
            type: "pie",
            radius: ["15%", "25%"],
            data: ZzNum_countrylist
          },
          {
            name: "省级龙头企业",
            type: "pie",
            radius: ["30%", "40%"],
            data: ZzNum_prolist
          },
          {
            name: "州市级龙头企业",
            type: "pie",
            radius: ["45%", "55%"],
            data: ZzNum_citylist
          },
          {
            name: "县区级龙头企业",
            type: "pie",
            radius: ["60%", "70%"],
            data: ZzNum_countylist
          },
          {
            name: "其他",
            type: "pie",
            radius: ["75%", "85%"],
            data: ZzNum_otherlist
          }
        ]
      };
      myChart.setOption(option);
    },
    initNmhzBar() {
      var self = this;
      let myChart = echarts.init(document.getElementById("nmhzBar"));
      let xlist = []; //x轴分类数组，即各个县市
      let HzNumlist = [];
      let HznhNumlist = [];
      let NmhzArealist = [];
      let HzlzArealist = [];
      let NmhzYincomelist = [];
      for (let i = 0; i < this.datalist.length - 1; i++) {
        let item = this.datalist[i];
        xlist.push(item.AreaName);
        HzNumlist.push(item.HzNum);
        HznhNumlist.push(item.HznhNum);
        NmhzArealist.push(item.NmhzArea);
        HzlzArealist.push(item.HzlzArea);
        NmhzYincomelist.push(item.NmhzYincome);
      }

      let option = {
        title: {
          text: "马铃薯农民合作社柱状图"
          // subtext: "纯属虚构"
        },
        tooltip: {
          trigger: "axis"
        },
        legend: {
          y: "30px",
          x: "left",
          data: ["马铃薯农民合作社", "参加马铃薯农民合作社农户数", "合作社经营面积", "流转土地面积", "合作社年销售收入"]
        },
        toolbox: {
          show: true,
          feature: {
            //dataView: { show: true, readOnly: false },
            //magicType: { show: true, type: ["line", "bar"] },
            //restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        calculable: true,
        xAxis: [
          {
            type: "category",
            data: xlist
          }
        ],
        yAxis: [
          {
            type: "value"
          }
        ],
        series: [
          {
            name: "马铃薯农民合作社数量",
            type: "bar",
            data: HzNumlist
          },
          {
            name: "参加马铃薯农民合作社农户数（户）",
            type: "bar",
            data: HznhNumlist
          },
          {
            name: "合作社经营面积（亩）",
            type: "bar",
            data: NmhzArealist
          },
          {
            name: "流转土地面积（亩）",
            type: "bar",
            data: HzlzArealist
          },
          {
            name: "合作社年销售收入（万元）",
            type: "bar",
            data: NmhzYincomelist
          }
        ]
      };
      myChart.setOption(option);
    },
    
    Download() {
      if(this.isCounty){
        window.open(this.$http.defaults.baseURL + "PotProsecution/GetExcelData?FillInYear=" + this.searchModel.FillInYear + "&&AreaCode=" + this.searchModel.AreaCode);
      }else{
        window.open(this.$http.defaults.baseURL +"PotProsecution/GetStatisExcel?FillInYear=" +this.searchModel.FillInYear +"&&AreaCode=" +this.searchModel.AreaCode);
      }
      
    },
    getListData() {
      var self = this;
      //判断当前用户是否为省级账号
      if(self.userInfo.AreaCode=="530000000000")
      {
          // self.isProvince=true;
          self.mapType=self.searchModel.AreaCode;
      }
      else{
          self.mapType=self.userInfo.AreaCode;
      }
      //地图数据
      //马铃薯市场
      self.MapMarketNumData=[],
      self.MapCdxMarketData=[],
      self.MapZypfMarketData=[],
      self.MapQyxzhpfMarketData=[],
      //马铃薯企业
      self.MapFruCompanyNumData=[],
      self.MapZzNum_CountryData=[],
      self.MapZzNum_ProData=[],
      self.MapZzNum_CityData=[],
      self.MapZzNum_AreaData=[],
      self.MapZzNum_OtherData=[],
      //马铃薯农民合作社
      self.MapHzNumData=[],
      self.MapNhNumData=[],
      // self.MapZyhzNumData=[],
      self.MapNmzyhzNumData=[],
      self.MapHzlzAreaData=[],//合作流转面积
      self.MapNmhzYincomeData=[],//合作社年销售收入（万元）
     
      self.mapList0=[],
      self.mapList1=[],
      self.mapList2=[],
      self.mapList3=[],
      self.mapList4=[];
      self.GeoData=self.GetGeoData(self.mapType); 
      this.$http.get("PotProsecution/GetStatisListData", {params: {AreaCode: this.searchModel.AreaCode,FillInYear: this.searchModel.FillInYear}}).then(function(res) {
          if (res.data.status == 1) {
            self.datalist = res.data.model;
            if (self.pieShow) {
              self.showPie();
            }
            self.CurrentAreaName=res.data.model[res.data.model.length-1].AreaName=="合计"?'云南省':res.data.model[res.data.model.length-1].AreaName;
            for(var i=0;i<res.data.model.length-1;i++)
            {
              //地图数据
              //马铃薯市场
              self.MapMarketNumData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].MarketNum});
              self.MapCdxMarketData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].CdxMarket});
              self.MapZypfMarketData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].ZypfMarket});
              self.MapQyxzhpfMarketData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].QyxzhpfMarket});
              //马铃薯企业
              self.MapFruCompanyNumData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].FruCompanyNum});
              self.MapZzNum_CountryData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].ZzNum_country});
              self.MapZzNum_ProData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].ZzNum_pro});
              self.MapZzNum_CityData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].ZzNum_county});
              self.MapZzNum_AreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].ZzNum_city});
              self.MapZzNum_OtherData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].ZzNum_other});
              //马铃薯农民合作社
              self.MapHzNumData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].HzNum});
              self.MapNhNumData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].HznhNum});
              self.MapNmzyhzNumData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].NmhzArea});
              self.MapHzlzAreaData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].HzlzArea});//合作流转面积
              self.MapNmhzYincomeData.push({'name':res.data.model[i].AreaName,'value':res.data.model[i].NmhzYincome});//合作社年销售收入（万元）
              
            }
            
            //地图数据
            self.mapList0.push(self.MapMarketNumData,self.MapCdxMarketData,self.MapZypfMarketData,self.MapQyxzhpfMarketData);
            self.mapList1.push(self.MapFruCompanyNumData,self.MapZzNum_CountryData,self.MapZzNum_ProData,self.MapZzNum_CityData,self.MapZzNum_AreaData,self.MapZzNum_OtherData);
            self.mapList2.push(self.MapHzNumData,self.MapNhNumData,self.MapNmzyhzNumData,self.MapHzlzAreaData,self.MapNmhzYincomeData);
            self.showMap();
          } else {
            self.$Modal.error({ title: "提示信息", content: res.data.message });
          }
        });
    },
    showMap(){
      var self=this;
      var containerTable=document.getElementsByClassName('ivu-col ivu-col-span-4');
      //******************显示地图
      
      var containerMapOne=document.getElementById('divMapOne');
      var containerMapTwo=document.getElementById('divMapTwo');
      var containerMapThree=document.getElementById('divMapThree');
      // //用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽
      var resizeContainerMap = function () {
          //containerTable[0].clientWidth 左侧菜单栏的宽度
          containerMapOne.style.width = (window.innerWidth- containerTable[0].clientWidth-22)+'px';
          containerMapOne.style.height = (window.innerHeight-280)+'px';
          containerMapTwo.style.width = (window.innerWidth- containerTable[0].clientWidth-22)+'px';
          containerMapTwo.style.height = (window.innerHeight-280)+'px';
          containerMapThree.style.width = (window.innerWidth- containerTable[0].clientWidth-22)+'px';
          containerMapThree.style.height = (window.innerHeight-280)+'px';
      };
      //设置容器高宽
      resizeContainerMap();

      var myMapOne = myEcharts.init(containerMapOne, 'shine');
      var myMapTwo = myEcharts.init(containerMapTwo, 'shine');
      var myMapThree = myEcharts.init(containerMapThree, 'shine');
      var MapNameOne=this.searchModel.FillInYear+'年(六)'+self.CurrentAreaName+'马铃薯市场统计地区分布图(全面统计)';
      var MapNameTwo=this.searchModel.FillInYear+'年(六)'+self.CurrentAreaName+'马铃薯企业统计地区分布图(全面统计)';
      var MapNameThree=this.searchModel.FillInYear+'年(六)'+self.CurrentAreaName+'马铃薯农民合作社统计地区分布图(全面统计)';
      var optionMapOne = self.GetMapOption(MapNameOne,self.GeoData,self.mapType,self.echartsItem0,self.mapList0);
      var optionMapTwo = self.GetMapOption(MapNameTwo,self.GeoData,self.mapType,self.echartsItem1,self.mapList1);
      var optionMapThree = self.GetMapOption(MapNameThree,self.GeoData,self.mapType,self.echartsItem2,self.mapList2);
      myMapOne.setOption(optionMapOne);
      myMapTwo.setOption(optionMapTwo);
      myMapThree.setOption(optionMapThree);
      //用于使chart自适应高度和宽度
      window.onresize = function () {
          //重置容器高宽
          resizeContainerMap();
          myMapOne.resize();
          myMapTwo.resize();
          myMapThree.resize();
      };
    },
    showLine(){
      var containerLine=document.getElementById('divLine');
      var containerTable=document.getElementsByClassName('ivu-col ivu-col-span-4');
      containerLine.style.width = (window.innerWidth- containerTable[0].clientWidth-42)+'px';
      containerLine.style.height = (window.innerHeight-320)+'px';
      var myChart = myEcharts.init(document.getElementById('divLine'), 'shine');
      var lineOption = this.getLineOption(this.PropDataList,this.propIndex,this.PropNameList[this.propIndex]);
      myChart.setOption(lineOption);
    },
    propChange(){
      this.showLine();
    },
    getAllYearStatisList(){
      var self = this;
      this.$http.get('PotProsecution/GetAllYearStatisList',{params: this.searchModel}).then(function(res){
        if(res.data.status==1){
          self.PropDataList = res.data.model;
        }
        else{
          self.$Modal.error({title:'提示信息',content:res.data.message});
        }
      });
    },
    getCountyListData(){
      var self = this;
      this.$http.get('PotProsecution', {params:{AreaCode:this.searchModel.AreaCode,FillInYear:this.searchModel.FillInYear}}).then(function (res) {
          if (res.data.status == 1) {
              self.DataModel = res.data.model.DataModel;
          }
          else {
              self.$Modal.error({ title: '提示信息', content: res.data.message });
          }
      });
    },
    checkData() {
      let message = '';
      let isOk = true;
      for (let i = 0; i < this.datalist.length; i++) {
        let Item = this.datalist[i];
        if(Item.MarketNum != Item.CdxMarket * 1 + Item.ZypfMarket * 1 + Item.QyxzhpfMarket * 1){
          isOk = false;
          message += Item.AreaName+ "马铃薯市场个数不等于其子项之和！</br>";
        } 
        if(Item.FruCompanyNum !=Item.ZzNum_country * 1 +Item.ZzNum_pro * 1 +Item.ZzNum_city * 1 +Item.ZzNum_county * 1 +Item.ZzNum_other * 1) {
          isOk = false;
          message += Item.AreaName+"马铃薯企业个数不等于其子项之和！</br>";
        }                
      }
      if(isOk){
        message += "数据检测无误！</br>";
      }
      return message;
    },
    toAlertCheckResult() {
      var message = this.checkData();
      this.$Modal.warning({
        title: "提示信息",
        content: message
      });
    },
    currentYear() {
      let year = new Date().getFullYear();
      let month = new Date().getMonth();
      if (month > 1) {
        this.searchModel.FillInYear = year.toString();
      } else {
        this.searchModel.FillInYear = (year - 1).toString();
      }
    },
    SearchCascaderChange() {
      if(this.searchModel.AreaCode.substr(4,2) !="00"){
          this.isCounty = true;
      }
      else{
          this.isCounty = false;
      }
      
      this.GetData();
    },
    getData(){
      this.getListData();
      this.getAllYearStatisList();
    }
  },
  //创建Vue页面方法
  created: function() {
    //this.currentYear();
    this.userInfo = this.GetlocaStorage("potUserinfo");
    this.AreaList = this.getChildAreaList(this.userInfo.AreaCode)
    this.getData();
  },
  watch: {
    //需要监听的在此处新增监听对象
  }
};
</script>

